import QtQuick 1.1;
import Qt 4.7
import com.nokia.meego 1.0;

PageStackWindow {
	id: rootWin;
	property int pageMargin: 16;

	Component.onCompleted: {
		theme.inverted = true;
	}

	signal launch(string wgtpath, string path, string startfile);
	signal quit(int exitcode);

	function showMessage(title, message) {
		messageDialog.titleText = title;
		messageDialog.message = message;
		messageDialog.open();
	}

	function showExitMessage(title, message) {
		exitMessageDialog.titleText = title;
		exitMessageDialog.message = message;
		exitMessageDialog.open();
	}

	function startWorking() {
		indicator.running = true;
		indicator.visible = true;
	}

	function stopWorking() {
		indicator.running = false;
		indicator.visible = false;
	}

	function openFile(file) {
		var component = Qt.createComponent(file);
		if (component.status == Component.Ready) {
			pageStack.push(component);
		} else {
			console.log("Error loading component:", component.errorString());
		}
	}

	BusyIndicator {
		id: indicator
		platformStyle: BusyIndicatorStyle { size: "large" }
		running: false;
		visible: false;
		anchors.centerIn: parent;
	}

	QueryDialog {
		id: messageDialog;
		acceptButtonText: "Okay";
	}

	QueryDialog {
		id: exitMessageDialog;
		acceptButtonText: "Okay";
		onAccepted: {
			quit(0);
		}
		onRejected: {
			quit(0);
		}
	}
}
